package leetcode.链表;


/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 小峰
 * Date: 2019-10-25
 * Time: 13:37
 * Url: https://leetcode-cn.com/problems/remove-linked-list-elements/
 */
public class _203_移除链表元素 {
    public static ListNode removeElements(ListNode head, int val) {
        ListNode newNode = new ListNode(val);
        newNode.next = head;
        ListNode cur=newNode;
        while (cur.next != null) {
            if (cur.next.val == val) {
                cur.next=cur.next.next;
            } else {
                cur = cur.next;
            }
        }
        return newNode.next;
    }
}
